package com.ruoyi.flink.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.flink.domain.JobConfig;
import com.ruoyi.flink.service.IJobConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * flink任务配置Controller
 * 
 * @author shu_k
 * @date 2021-04-23
 */
@RestController
@RequestMapping("/streaming/JobConfig")
public class JobConfigController extends BaseController
{
    @Autowired
    private IJobConfigService jobConfigService;

    /**
     * 查询flink任务配置列表
     */
    @PreAuthorize("@ss.hasPermi('flink:JobConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(JobConfig jobConfig)
    {
        startPage();
        List<JobConfig> list = jobConfigService.selectJobConfigList(jobConfig);
        return getDataTable(list);
    }

    /**
     * 导出flink任务配置列表
     */
    @PreAuthorize("@ss.hasPermi('flink:JobConfig:export')")
    @Log(title = "flink任务配置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(JobConfig jobConfig)
    {
        List<JobConfig> list = jobConfigService.selectJobConfigList(jobConfig);
        ExcelUtil<JobConfig> util = new ExcelUtil<JobConfig>(JobConfig.class);
        return util.exportExcel(list, "flink任务配置数据");
    }

    /**
     * 获取flink任务配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('flink:JobConfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(jobConfigService.selectJobConfigById(id));
    }

    /**
     * 新增flink任务配置
     */
    @PreAuthorize("@ss.hasPermi('flink:JobConfig:add')")
    @Log(title = "flink任务配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JobConfig jobConfig)
    {
        return toAjax(jobConfigService.insertJobConfig(jobConfig));
    }

    /**
     * 修改flink任务配置
     */
    @PreAuthorize("@ss.hasPermi('flink:JobConfig:edit')")
    @Log(title = "flink任务配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JobConfig jobConfig)
    {
        return toAjax(jobConfigService.updateJobConfig(jobConfig));
    }

    /**
     * 删除flink任务配置
     */
    @PreAuthorize("@ss.hasPermi('flink:JobConfig:remove')")
    @Log(title = "flink任务配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(jobConfigService.deleteJobConfigByIds(ids));
    }
}
